#ifndef WXSCOLOURPROPERTY_H
#define WXSCOLOURPROPERTY_H

#include "../../properties/wxsproperties.h"
#include "../wxscodercontext.h"
#include <wx/dialog.h>
#include <wx/propgrid/propdev.h>
#include <wx/propgrid/advprops.h>
#define wxsCOLOUR_DEFAULT   (wxPG_COLOUR_CUSTOM - 1)


class wxsColourData: public wxColourPropertyValue {
  public:

    wxsColourData( wxUint32 type, const wxColour &colour ): wxColourPropertyValue( type, colour ) {}
    wxsColourData( wxUint32 type = wxsCOLOUR_DEFAULT ): wxColourPropertyValue( type ) {}
    wxsColourData( const wxColour &colour ): wxColourPropertyValue( colour ) {}
    wxsColourData( const wxColourPropertyValue& cp ): wxColourPropertyValue( cp ) {}


    wxColour GetColour();


    wxString BuildCode( wxsCoderContext* Context );
};


class wxsColourProperty: public wxsProperty {
  public:


    wxsColourProperty(
      const wxString& PGName,
      const wxString& DataName,
      long ValueOffset,
      int Priority = 100 );


    virtual const wxString GetTypeName() { return _T( "wxsColour" ); }


    static wxColour GetColour( const wxColourPropertyValue& value );


    static wxString GetColourCode( const wxColourPropertyValue& value, wxsCodingLang Language );

  protected:

    virtual void PGCreate( wxsPropertyContainer* Object, wxPropertyGridManager* Grid, wxPGId Parent );
    virtual bool PGRead( wxsPropertyContainer* Object, wxPropertyGridManager* Grid, wxPGId Id, long Index );
    virtual bool PGWrite( wxsPropertyContainer* Object, wxPropertyGridManager* Grid, wxPGId Id, long Index );
    virtual bool XmlRead( wxsPropertyContainer* Object, TiXmlElement* Element );
    virtual bool XmlWrite( wxsPropertyContainer* Object, TiXmlElement* Element );
    virtual bool PropStreamRead( wxsPropertyContainer* Object, wxsPropertyStream* Stream );
    virtual bool PropStreamWrite( wxsPropertyContainer* Object, wxsPropertyStream* Stream );

  private:
    long ValueOffset;
};




#define WXS_COLOUR(ClassName,VarName,PGName,DataName) \
  { static wxsColourProperty _Property(PGName,DataName,wxsOFFSET(ClassName,VarName)); \
    Property(_Property); }


#define WXS_COLOUR_P(ClassName,VarName,PGName,DataName,Priority) \
  { static wxsColourProperty _Property(PGName,DataName,wxsOFFSET(ClassName,VarName),Priority); \
    Property(_Property); }



#endif
